package day06;

import java.util.Scanner;

public class HW5 {
/*请编写⼀个Java程序，实现从键盘中输⼊年份 ⽉份 ⽇期，输出这⼀天是该年的第⼏天 
【要求】
输⼊的年份、⽉份、⽇期均为数字，不⾜10的⽤0x表 
示，如：1⽉1⽇为01 01 
输⼊的年份、⽉份、⽇期之间⽤空格隔开，如：2023 04 27
【示例】 
输⼊：2023 04 27 
输出：117 */
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        System.out.println("请输入年份：");
        int year = scan.nextInt();
        System.out.println("请输入月份：");
        int month = scan.nextInt();
        System.out.println("请输入日期：");
        int day = scan.nextInt();
        scan.close();
        
        int totalDays = 0;

        switch (month) {
            case 12:
                totalDays += 30;
            case 11:
                totalDays += 31;
            case 10:
                totalDays += 30;
            case 9:
                totalDays += 31;
            case 8:
                totalDays += 31;
            case 7:
                totalDays += 30;
            case 6:
                totalDays += 31;
            case 5:
                totalDays += 30;
            case 4:
                totalDays += 31;
            case 3:
                if (month > 2) {
            if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)) {
                totalDays += 29; 
            } else {
                totalDays += 28; 
            }
        }
            case 2:
                totalDays += 31;
            case 1:
                totalDays += day;
        }

        System.out.printf("%d年%d月%d日是该年的第%d天\n", year, month, day, totalDays);
    }
}

